import httpx
class executeSqlFile:
    def __init__(self, sql_file):
        # url = "http://127.0.0.1:48080/app-api/douyinFileInfo/invoke"
        url = "https://ppru.cn/api/douyinFileInfo/invoke"
        batch_size = 100
        invoke = ""
        # 读取SQL文件内容
        with open(sql_file, 'r',encoding="utf-8") as file:
            sql_script = file.read().split(";")
            # 使用 MySQL 连接执行 SQL 语句
        for (index,sql) in enumerate(sql_script):
            invoke += sql + ";"
            if (index+1) % batch_size == 0 or index == len(sql_script)-1:
                try:
                    httpx.post(url=url, json={"sql": invoke},timeout=None)
                except Exception:
                    print("请求失败")
                invoke = ""

